<?php
    use yii\helpers\Html;
    use yii\helpers\Url;
    use yii\widgets\LinkPager;
?>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">

            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>VIP列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="form-group form-horizontal form-style">
                        <form class="" action="">
                            <div class="row m-b">
                                <label class="col-sm-1 control-label">关键词</label>
                                <div class="col-sm-2">
                                    <input type="text" name="keyword" value="<?= $keyword?>" class="form-control" placeholder="输入学生ID、名称或手机号">
                                </div>
                                <label class="col-sm-1 control-label">VIP</label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="vip">
                                        <option value="">全部</option>
                                        <option value="1" <?=$vip == 1 ? 'selected':''?> >VIP</option>
                                    </select>
                                </div>
                                <div class="col-sm-2">
                                    <button type="submit" class="btn btn-primary">搜索</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <?= \yii\grid\GridView::widget([
                        'dataProvider' => $dataProvider,
                        'rowOptions' => function($model, $key, $index, $grid){
                            return ['data-id' => $model->id];
                        },
                        'tableOptions'=>['class'=>'table table-striped table-bordered table-hover'],
                        'summary'=>'{begin}-{end}，共{totalCount}条数据，共{pageCount}页',
                        'pager' =>['class' => \backend\utils\GoPager::className()],
                        'columns' => [
                            'id',
                            'nickname:text',
                            [
                                'attribute'=>'iconImg',
                                'format'=>'html',
                                'label'=>'头像',
                            ],
                            [
                                'label'=>'电话号码',
                                'attribute'=>'resetTelephone',
                            ],
                            [
                                'label'=>'是否VIP',
                                'attribute'=>'vipName',
                            ],
                            [
                                'attribute'=>'formatDate',
                                'label'=>'注册时间',
                            ],
                            [
                                'header'=>'操作',
                                'class' => 'yii\grid\ActionColumn',
                                'template'=>'{vip}',
                                'buttons'=>[
                                    'vip'=>function($url,$model){
                                        if(!$this->context->isAuth('user/vip-ajax-do')) return '';
                                        if($model->vip==1){
                                            return Html::a('取消VIP','#', ['url'=>'vip-ajax-do','data-vip'=>0,'class' => 'btn btn-xs btn-warning ajax_action']);
                                        }else{
                                            return Html::a('设置VIP','#', ['url'=>'vip-ajax-do','data-vip'=>1,'class' => 'btn btn-xs btn-primary ajax_action']);
                                        }
                                    }
                                ],
                            ],

                        ],
                    ]); ?>
                </div>
            </div>
        </div>
    </div>